package com.coldtech.circlecrash.gui;

import java.awt.Graphics2D;

import com.coldtech.circlecrash.Sprite;
import com.coldtech.circlecrash.SpriteSheet;
import com.coldtech.circlecrash.handler.ButtonHandler;

public class ImageButton extends Button {
	private Sprite sprite = null;

	public ImageButton(ButtonHandler buttonHandler, Sprite sprite, int x, int y) {
		super(buttonHandler, x, y, 48, 48);
		this.sprite = sprite;
	}

	public void draw(Graphics2D g) {
		Sprite buttonSprite = SpriteSheet.IMAGEBUTTON.getSprite(
				this.getState(), 0);
		if (buttonSprite != null) {
			g.drawImage(buttonSprite.getImage(), getX(), getY(),
					buttonSprite.getWidth(), buttonSprite.getHeight(), null);
		}
		if (sprite != null) {
			g.drawImage(sprite.getImage(), getX(), getY(), sprite.getWidth(),
					sprite.getHeight(), null);
		}
	}
}
